{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9939b87f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dd63ceaf",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.abc import x,y,z,t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a7acbeda",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=[12,-10,10,-8,-6,-5,-3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "565eb0cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-10"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c69d244b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def list_sum_list(a):\n",
    "    b=[]\n",
    "    old_sum=0\n",
    "    for i in a:\n",
    "        old_sum+=i\n",
    "        b.append(old_sum)\n",
    "    return b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2db06218",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[12, 2, 12, 4, -2, -7, -10]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list_sum_list(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a914b3da",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "fc402a0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{45\\right\\}$"
      ],
      "text/plain": [
       "{45}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(Eq(3*t-15,30+2*t),t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5c795d75",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{-3\\right\\}$"
      ],
      "text/plain": [
       "{-3}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(Eq(-3*t+15,30+2*t),t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5a456bd1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(-7)+(-15)-(-25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f3b21d37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{12}{7}$"
      ],
      "text/plain": [
       "12/7"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(-Rational(2,7)-(-Rational(1,2))+abs(-(1+Rational(1,2))))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "809455b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "23"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(-7)+(-15)*(-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2cfbf212",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 5000$"
      ],
      "text/plain": [
       "5000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Rational((275+(-15)-10),5)*(7*5+13*5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "6bdcbdea",
   "metadata": {},
   "outputs": [],
   "source": [
    "out_in=[-950,500,-800,1200,-1025,2500,-200]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "95327d24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-950, -450, -1250, -50, -1075, 1425, 1225]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list_sum_list(out_in)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1c84ef67",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.is_Rational"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5e15d77b",
   "metadata": {},
   "outputs": [],
   "source": [
    "def delt_reciprocal(a):\n",
    "    b=simplify(a)\n",
    "    if b.is_Rational:\n",
    "        if b != 1 :\n",
    "            return 1/(1-b)\n",
    "        else:\n",
    "            return None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "94806d69",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on bool object:\n",
      "\n",
      "class bool(int)\n",
      " |  bool(x) -> bool\n",
      " |  \n",
      " |  Returns True when the argument x is true, False otherwise.\n",
      " |  The builtins True and False are the only two instances of the class bool.\n",
      " |  The class bool is a subclass of the class int, and cannot be subclassed.\n",
      " |  \n",
      " |  Method resolution order:\n",
      " |      bool\n",
      " |      int\n",
      " |      object\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __and__(self, value, /)\n",
      " |      Return self&value.\n",
      " |  \n",
      " |  __or__(self, value, /)\n",
      " |      Return self|value.\n",
      " |  \n",
      " |  __rand__(self, value, /)\n",
      " |      Return value&self.\n",
      " |  \n",
      " |  __repr__(self, /)\n",
      " |      Return repr(self).\n",
      " |  \n",
      " |  __ror__(self, value, /)\n",
      " |      Return value|self.\n",
      " |  \n",
      " |  __rxor__(self, value, /)\n",
      " |      Return value^self.\n",
      " |  \n",
      " |  __xor__(self, value, /)\n",
      " |      Return self^value.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(*args, **kwargs) from builtins.type\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Methods inherited from int:\n",
      " |  \n",
      " |  __abs__(self, /)\n",
      " |      abs(self)\n",
      " |  \n",
      " |  __add__(self, value, /)\n",
      " |      Return self+value.\n",
      " |  \n",
      " |  __bool__(self, /)\n",
      " |      True if self else False\n",
      " |  \n",
      " |  __ceil__(...)\n",
      " |      Ceiling of an Integral returns itself.\n",
      " |  \n",
      " |  __divmod__(self, value, /)\n",
      " |      Return divmod(self, value).\n",
      " |  \n",
      " |  __eq__(self, value, /)\n",
      " |      Return self==value.\n",
      " |  \n",
      " |  __float__(self, /)\n",
      " |      float(self)\n",
      " |  \n",
      " |  __floor__(...)\n",
      " |      Flooring an Integral returns itself.\n",
      " |  \n",
      " |  __floordiv__(self, value, /)\n",
      " |      Return self//value.\n",
      " |  \n",
      " |  __format__(self, format_spec, /)\n",
      " |      Default object formatter.\n",
      " |  \n",
      " |  __ge__(self, value, /)\n",
      " |      Return self>=value.\n",
      " |  \n",
      " |  __getattribute__(self, name, /)\n",
      " |      Return getattr(self, name).\n",
      " |  \n",
      " |  __getnewargs__(self, /)\n",
      " |  \n",
      " |  __gt__(self, value, /)\n",
      " |      Return self>value.\n",
      " |  \n",
      " |  __hash__(self, /)\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __index__(self, /)\n",
      " |      Return self converted to an integer, if self is suitable for use as an index into a list.\n",
      " |  \n",
      " |  __int__(self, /)\n",
      " |      int(self)\n",
      " |  \n",
      " |  __invert__(self, /)\n",
      " |      ~self\n",
      " |  \n",
      " |  __le__(self, value, /)\n",
      " |      Return self<=value.\n",
      " |  \n",
      " |  __lshift__(self, value, /)\n",
      " |      Return self<<value.\n",
      " |  \n",
      " |  __lt__(self, value, /)\n",
      " |      Return self<value.\n",
      " |  \n",
      " |  __mod__(self, value, /)\n",
      " |      Return self%value.\n",
      " |  \n",
      " |  __mul__(self, value, /)\n",
      " |      Return self*value.\n",
      " |  \n",
      " |  __ne__(self, value, /)\n",
      " |      Return self!=value.\n",
      " |  \n",
      " |  __neg__(self, /)\n",
      " |      -self\n",
      " |  \n",
      " |  __pos__(self, /)\n",
      " |      +self\n",
      " |  \n",
      " |  __pow__(self, value, mod=None, /)\n",
      " |      Return pow(self, value, mod).\n",
      " |  \n",
      " |  __radd__(self, value, /)\n",
      " |      Return value+self.\n",
      " |  \n",
      " |  __rdivmod__(self, value, /)\n",
      " |      Return divmod(value, self).\n",
      " |  \n",
      " |  __rfloordiv__(self, value, /)\n",
      " |      Return value//self.\n",
      " |  \n",
      " |  __rlshift__(self, value, /)\n",
      " |      Return value<<self.\n",
      " |  \n",
      " |  __rmod__(self, value, /)\n",
      " |      Return value%self.\n",
      " |  \n",
      " |  __rmul__(self, value, /)\n",
      " |      Return value*self.\n",
      " |  \n",
      " |  __round__(...)\n",
      " |      Rounding an Integral returns itself.\n",
      " |      Rounding with an ndigits argument also returns an integer.\n",
      " |  \n",
      " |  __rpow__(self, value, mod=None, /)\n",
      " |      Return pow(value, self, mod).\n",
      " |  \n",
      " |  __rrshift__(self, value, /)\n",
      " |      Return value>>self.\n",
      " |  \n",
      " |  __rshift__(self, value, /)\n",
      " |      Return self>>value.\n",
      " |  \n",
      " |  __rsub__(self, value, /)\n",
      " |      Return value-self.\n",
      " |  \n",
      " |  __rtruediv__(self, value, /)\n",
      " |      Return value/self.\n",
      " |  \n",
      " |  __sizeof__(self, /)\n",
      " |      Returns size in memory, in bytes.\n",
      " |  \n",
      " |  __sub__(self, value, /)\n",
      " |      Return self-value.\n",
      " |  \n",
      " |  __truediv__(self, value, /)\n",
      " |      Return self/value.\n",
      " |  \n",
      " |  __trunc__(...)\n",
      " |      Truncating an Integral returns itself.\n",
      " |  \n",
      " |  as_integer_ratio(self, /)\n",
      " |      Return integer ratio.\n",
      " |      \n",
      " |      Return a pair of integers, whose ratio is exactly equal to the original int\n",
      " |      and with a positive denominator.\n",
      " |      \n",
      " |      >>> (10).as_integer_ratio()\n",
      " |      (10, 1)\n",
      " |      >>> (-10).as_integer_ratio()\n",
      " |      (-10, 1)\n",
      " |      >>> (0).as_integer_ratio()\n",
      " |      (0, 1)\n",
      " |  \n",
      " |  bit_length(self, /)\n",
      " |      Number of bits necessary to represent self in binary.\n",
      " |      \n",
      " |      >>> bin(37)\n",
      " |      '0b100101'\n",
      " |      >>> (37).bit_length()\n",
      " |      6\n",
      " |  \n",
      " |  conjugate(...)\n",
      " |      Returns self, the complex conjugate of any int.\n",
      " |  \n",
      " |  to_bytes(self, /, length, byteorder, *, signed=False)\n",
      " |      Return an array of bytes representing an integer.\n",
      " |      \n",
      " |      length\n",
      " |        Length of bytes object to use.  An OverflowError is raised if the\n",
      " |        integer is not representable with the given number of bytes.\n",
      " |      byteorder\n",
      " |        The byte order used to represent the integer.  If byteorder is 'big',\n",
      " |        the most significant byte is at the beginning of the byte array.  If\n",
      " |        byteorder is 'little', the most significant byte is at the end of the\n",
      " |        byte array.  To request the native byte order of the host system, use\n",
      " |        `sys.byteorder' as the byte order value.\n",
      " |      signed\n",
      " |        Determines whether two's complement is used to represent the integer.\n",
      " |        If signed is False and a negative integer is given, an OverflowError\n",
      " |        is raised.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods inherited from int:\n",
      " |  \n",
      " |  from_bytes(bytes, byteorder, *, signed=False) from builtins.type\n",
      " |      Return the integer represented by the given array of bytes.\n",
      " |      \n",
      " |      bytes\n",
      " |        Holds the array of bytes to convert.  The argument must either\n",
      " |        support the buffer protocol or be an iterable object producing bytes.\n",
      " |        Bytes and bytearray are examples of built-in objects that support the\n",
      " |        buffer protocol.\n",
      " |      byteorder\n",
      " |        The byte order used to represent the integer.  If byteorder is 'big',\n",
      " |        the most significant byte is at the beginning of the byte array.  If\n",
      " |        byteorder is 'little', the most significant byte is at the end of the\n",
      " |        byte array.  To request the native byte order of the host system, use\n",
      " |        `sys.byteorder' as the byte order value.\n",
      " |      signed\n",
      " |        Indicates whether two's complement is used to represent the integer.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors inherited from int:\n",
      " |  \n",
      " |  denominator\n",
      " |      the denominator of a rational number in lowest terms\n",
      " |  \n",
      " |  imag\n",
      " |      the imaginary part of a complex number\n",
      " |  \n",
      " |  numerator\n",
      " |      the numerator of a rational number in lowest terms\n",
      " |  \n",
      " |  real\n",
      " |      the real part of a complex number\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(x.is_Rational)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "76386462",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{1}{2}$"
      ],
      "text/plain": [
       "-1/2"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delt_reciprocal(3)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "12c75a9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, -1, 1/2, 2, -1]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer=[2]\n",
    "for i in range(1,5):\n",
    "    answer.append(delt_reciprocal(answer[i-1]))\n",
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "50775e03",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sum in module builtins:\n",
      "\n",
      "sum(iterable, /, start=0)\n",
      "    Return the sum of a 'start' value (default: 0) plus an iterable of numbers\n",
      "    \n",
      "    When the iterable is empty, return the start value.\n",
      "    This function is intended specifically for use with numeric values and may\n",
      "    reject non-numeric types.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "114271cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{3}{2}$"
      ],
      "text/plain": [
       "3/2"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer[0]+answer[1]+answer[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "023ba140",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " -1,\n",
       " 1/2,\n",
       " 2,\n",
       " ...]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer=[2]\n",
    "for i in range(1,2023):\n",
    "    answer.append(delt_reciprocal(answer[i-1]))\n",
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "368fa48c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2023"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 248,
   "id": "3cafcf4e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2$"
      ],
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 248,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer[2022]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "9d34887a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1013$"
      ],
      "text/plain": [
       "1013"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "040acc35",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 30$"
      ],
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((-Rational(1,3))**3*3**3+(-3)**2)*5*(1-(-Rational(1,2))**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "1156d1c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 100$"
      ],
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(283**2021+(-283)**2021-10)*(-2)/abs(-Rational(1,5))*(-1)**2020"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "abccd819",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.18"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3*1.23+1.49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "c949a23d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8.75"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2*2.50+3*1.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "de4e3349",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{1}{32}$"
      ],
      "text/plain": [
       "1/32"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(-Rational(1,8))**2022*2**2021*4**2020"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "d97affa1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def new_calc(x,y):\n",
    "    return x*y+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "4b9bef44",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-9"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_calc(new_calc(1,4),-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "f6639779",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x y + 1$"
      ],
      "text/plain": [
       "x*y + 1"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_calc(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "8130cc5a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x y + x z + 1$"
      ],
      "text/plain": [
       "x*y + x*z + 1"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(new_calc(x,(y+z)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "f0e13d1e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x y + 1$"
      ],
      "text/plain": [
       "x*y + 1"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_calc(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "487351df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x z + 1$"
      ],
      "text/plain": [
       "x*z + 1"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_calc(x,z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "944616b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -1$"
      ],
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand(new_calc(x,(y+z)))-new_calc(x,y)-new_calc(x,z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "79e878a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.abc import a,b,c,m,n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "09419b7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(a, b, m, n)"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a,b,m,n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "80f35237",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a b - 4 a + 4 b - 4 c$"
      ],
      "text/plain": [
       "a*b - 4*a + 4*b - 4*c"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a*b-4*(a-b+c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "92032b7d",
   "metadata": {},
   "outputs": [],
   "source": [
    "b,c=symbols(\"b,c\",negative=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "2c164f90",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=symbols(\"a\",positive=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "15bd632e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{True}$"
      ],
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a>0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "7a90276b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a - c - \\left|{a + b}\\right| + \\left|{b - c}\\right|$"
      ],
      "text/plain": [
       "a - c - Abs(a + b) + Abs(b - c)"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify(abs(c-a)-abs(a+b)+abs(b-c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "4b95e376",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.abc import a,b,c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "fcc2be0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "A=a**2+b**2-c**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "bcfea5f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a^{2} + b^{2} - c^{2}$"
      ],
      "text/plain": [
       "a**2 + b**2 - c**2"
      ]
     },
     "execution_count": 141,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "id": "3a1ac4fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "B=-4*a**2+2*b**2+3*c**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "dd30b739",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 4 a^{2} + 2 b^{2} + 3 c^{2}$"
      ],
      "text/plain": [
       "-4*a**2 + 2*b**2 + 3*c**2"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "b12e105b",
   "metadata": {},
   "outputs": [],
   "source": [
    "C=-(A+B)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "70dab4d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 3 a^{2} - 3 b^{2} - 2 c^{2}$"
      ],
      "text/plain": [
       "3*a**2 - 3*b**2 - 2*c**2"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "id": "5aa3094f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 18$"
      ],
      "text/plain": [
       "18"
      ]
     },
     "execution_count": 146,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(A+B).subs([(a,1),(b,-1),(c,3)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "id": "dd0dfbc2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 6 a + 21$"
      ],
      "text/plain": [
       "6*a + 21"
      ]
     },
     "execution_count": 250,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simplify((a+5)**2-(a+2)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "id": "94d4b318",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\left(a + 2\\right)^{2} + \\left(a + 5\\right)^{2}$"
      ],
      "text/plain": [
       "-(a + 2)**2 + (a + 5)**2"
      ]
     },
     "execution_count": 249,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((a+5)**2-(a+2)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "5ae70826",
   "metadata": {},
   "outputs": [],
   "source": [
    "f=lambda n:(-1)**n*(2*n-1)*x**n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "8a900b6a",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=[]\n",
    "for i in range(1,10):\n",
    "    answer.append(f(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "9ade9428",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 4041 x^{2021}$"
      ],
      "text/plain": [
       "-4041*x**2021"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f(2021)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "9b8c0185",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 4043 x^{2022}$"
      ],
      "text/plain": [
       "4043*x**2022"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f(2022)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "86deb183",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.1666666666666667"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "7/6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "id": "20cbc711",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x^{3} - 3 x^{2} y + 3 x y^{2} - y^{3}$"
      ],
      "text/plain": [
       "x**3 - 3*x**2*y + 3*x*y**2 - y**3"
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expand((x-y)**3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "id": "1ba307fb",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr=(4*x**2*y+5*x*y-7*x)-Rational(1,2)*(4*x**2*y+10*x*y-14*x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "id": "40c4e280",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2 x^{2} y$"
      ],
      "text/plain": [
       "2*x**2*y"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "id": "91a33162",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -4$"
      ],
      "text/plain": [
       "-4"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.subs([(x,1),(y,-2)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "id": "16dadb67",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr1=-2*(x*y-3*x**2)-(x**2-5*(x*y-x**2)+2*x*y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "id": "231f028a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle x y$"
      ],
      "text/plain": [
       "x*y"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "27bcbda3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -1$"
      ],
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr1.subs([(x,1),(y,-1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "id": "7c62d163",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr2=3*(x**2+2*(y**2+x*y-2))-3*(x**2+2*y**2)-4*(x*y-x-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "id": "e5bc6757",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 2 x y + 4 x - 8$"
      ],
      "text/plain": [
       "2*x*y + 4*x - 8"
      ]
     },
     "execution_count": 174,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "id": "66dcb7cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{3}{2}$"
      ],
      "text/plain": [
       "3/2"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve(expr2.subs(x*y,1),x)[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "id": "22b99d27",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab242e96",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "2e1277ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer=(pi-acos(Rational(1,3)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "cf039235",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\pi - \\operatorname{acos}{\\left(\\frac{1}{3} \\right)}$"
      ],
      "text/plain": [
       "pi - acos(1/3)"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "26fb434d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1.91063323624902$"
      ],
      "text/plain": [
       "1.91063323624902"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "N(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "id": "2ed50740",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "28.27323806944662"
      ]
     },
     "execution_count": 197,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(np.rad2deg(1.91063323624902)-109)*60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "id": "f2976c73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(4)==int"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 212,
   "id": "947eabde",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 212,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "int(3.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "id": "aae109b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "def three_times_plus_one(a):\n",
    "    chain=[a]\n",
    "    if type(a)==int:\n",
    "        while(a!=1):\n",
    "            if(a%2==0):\n",
    "                a=int(a/2)\n",
    "            else:\n",
    "                a=3*a+1\n",
    "            chain.append(a)\n",
    "                \n",
    "    return chain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 214,
   "id": "7a5d884e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3, 10, 5, 16, 8, 4, 2, 1]"
      ]
     },
     "execution_count": 214,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "three_times_plus_one(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 215,
   "id": "4512b67c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]"
      ]
     },
     "execution_count": 215,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "three_times_plus_one(11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 216,
   "id": "af411bac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle -1$"
      ],
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 216,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "-2**2*(2+Rational(1,4))+(-3)**3*(-Rational(8,27))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "id": "97943175",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 1$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 221,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "-1**2022+81*Rational(1,(-3)**3)*abs(-Rational(1,3))-24*(Rational(1,6)-Rational(7,24))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 223,
   "id": "419d8f4d",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr3=2*(x*y**2+Rational(1,2)*x**2*y)-(2*x*y**2-3*(1-x**2*y))-2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 224,
   "id": "d9a77444",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - 2 x^{2} y + 1$"
      ],
      "text/plain": [
       "-2*x**2*y + 1"
      ]
     },
     "execution_count": 224,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 225,
   "id": "6c426228",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 0$"
      ],
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 225,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr3.subs([(x,-1),(y,Rational(1,2))])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 252,
   "id": "8e576dc3",
   "metadata": {},
   "outputs": [],
   "source": [
    "price=5880"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "id": "5f19a422",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5586.0"
      ]
     },
     "execution_count": 253,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.95*price"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "id": "bb7473b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5592.0"
      ]
     },
     "execution_count": 254,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.9*price+300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 226,
   "id": "d5d76361",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 226,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(21.9/24)/(365/400)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "id": "2900586d",
   "metadata": {},
   "outputs": [],
   "source": [
    "expr4=(4*n**2-3*m)-(-3*(m-Rational(1,3)*n**2)+m)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "id": "9b426127",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - m + 3 n^{2}$"
      ],
      "text/plain": [
       "-m + 3*n**2"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "id": "12dbe11b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{37}{3}$"
      ],
      "text/plain": [
       "37/3"
      ]
     },
     "execution_count": 230,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr4.subs([(m,-Rational(1,3)),(n,-2)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "id": "172fe01d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def star_calc(a,b):\n",
    "    return a*b**2+2*a*b+a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "id": "616bdd01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 256,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "star_calc(1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 240,
   "id": "4afca5d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-32"
      ]
     },
     "execution_count": 240,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "star_calc(-2,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "id": "ef05f925",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{0\\right\\}$"
      ],
      "text/plain": [
       "{0}"
      ]
     },
     "execution_count": 257,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solveset(star_calc((a+1)/2,3)-8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c2f8b53",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
